import request from '@/api/axios/request.js'


export default {
  // 用户登陆
  userLogin(email,password){
    return request({
      url:'login',
      method:'post',
      data:{
        email,
        password
      }
    })
  },

  // 用户注册
  userRegister(email,password,ip){
    return request({
      url:'register',
      method:'post',
      data:{
        email,
        password,
        ip
      }
    })
  },

  // 发送邮件
  sendEmail(addressee){
    return request({
      url:'sendEmail',
      method:'post',
      data:{
        addressee,
      }
    })
  },

  // 用户中心数据获取  header携带token
  userCenterInfo(){
    return request({
      url:'getUserInfo',
      method:'post',
    })
  },

  // 用户中心数据更新  header携带token
  updateUserCenterInfo(UserInfo){
    return request({
      url:'modifiy',
      method:'post',
      data:{
        username:UserInfo.username,
        sex:UserInfo.sex,
        workAddress:UserInfo.workAddress,
        familyAddress:UserInfo.familyAddress,
        personIntro:UserInfo.personIntro,
        email:UserInfo.email
      }
    })
  },


  // 用户中心头像更换
  updateAvatar(avatar){
    return request({
      url:'updateAvatar',
      method:'post',
      data:{
        avatar
      }
    })
  },


  // 用户中心头像更换
  updatePassword(User){
    return request({
      url:'updatePassword',
      method:'post',
      data:{
        email:User.email,
        password:User.password
      }
    })
  },

  // 用户中心头像更换
  LoginStatus(){
    return request({
      url:'loginStatus',
      method:'post',
    })
  },


  releaseArticle(context) {
    return request({
      url: 'article/releaseArticle',
      method: 'post',
      data:{
        title:context.title,
        context:context.value,
        userId:context.uid,
        coverImg:context.coverImg,
        articleCatalogId:context.catalog,
        articleType:context.type,
        articleForm:context.form[0],
        labels:context.labels
      }
    })
  },

  selectArticleById(id) {
    return request({
      url: 'article/selectArticleById',
      method: 'post',
      data:{
        id
      }
    })
  },


  getAllArticle(uid) {
    return request({
      url: 'article/getAllArticle',
      method: 'post',
      data:{
        userId:uid
      }
    })
  },

  deleteArticleById(id) {
    return request({
      url: 'article/deleteArticleById',
      method: 'post',
      data:{
        id
      }
    })
  },


  getInfoById(id) {
    return request({
      url: 'getInfoById',
      method: 'post',
      data:{
        id
      }
    })
  },

  getUserList(pages,pageNum) {
    return request({
      url: 'getAllUser',
      method: 'post',
      data:{
        pages,
        pageNum
      }
    })
  },


  UpdateUserInfo(formData) {
    return request({
      url: 'modifiy',
      method: 'post',
      data:{
        email:formData.email,
        familyAddress:formData.familyAddress,
        password:formData.password,
        personIntro:formData.personIntro,
        username:formData.username,
        workAddress:formData.workAddress,
        sex:formData.sex
      }
    })
  },
  
  
  deleteUser(id) {
    return request({
      url: 'deleteUser',
      method: 'post',
      data:{
        id
      }
    })
  },
  
}
